/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 *
 *MmsResponseController
 * 意见反馈回复表
 *
 * 修改纪录
 * 2021-10-29 版本：1.0 zhangqianbo 创建。
 * @version 版本：1.0
 * @author 作者：zhangqianbo
 * 创建日期：2021-10-29
 */

package com.topscomm.mms.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.topscomm.mms.pojo.MmsResponseEntity;
import com.topscomm.pub.util.ConvertUtil;
import org.springframework.web.bind.annotation.*;

import com.topscomm.mms.controller.auto.MmsResponseControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: zhangqianbo
 * @date: 2021-10-29
 * @description:意见反馈回复表Controller
 * @modify:
 */
@RestController
@RequestMapping("mms/response")
public class MmsResponseController extends MmsResponseControllerAuto implements IMmsResponseController {
	/**
	 * @author: zhangqianbo
	 * @date: 2021-10-29
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_name")) {
			String value = paraMap.get("qry_name").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and name like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_code")) {
			String value = paraMap.get("qry_code").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and code = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: zhangqianbo
	 * @date: 2021-10-29
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}


	/**
	 * @author: zhangqianbo
	 * @date: 2021-10-29
	 * @param paraMap
	 * @return
	 * @description:
	 * @modify:
	 */
	@GetMapping(value = "/responseList")
	public ResponseResult<Object> responseListInfo(@RequestParam(required = false) Map<String, Object> paraMap) {
		String sourceid = ConvertUtil.convertToString(paraMap.get("qry_sourceid"));
		String sourcetype = ConvertUtil.convertToString(paraMap.get("qry_sourcetype"));
		StringBufferProxy sqlWhere = new StringBufferProxy();
//		sqlWhere.appendSingle("sourceid = {0} and sourcetype = '{1}'", sourceid, sourcetype);
		sqlWhere.appendSingle("sourceid = {0} ORDER BY MODIFIEDON DESC", sourceid);
		List<MmsResponseEntity> mmsResponseEntities = this.service.queryByWhere(sqlWhere.toString());
		return ResponseResult.ok(mmsResponseEntities);
	}

}

